package BoostedTest::C::Testplans;

use strict;
use warnings;
use base qw[ Catalyst::Controller ];
use BoostedTest::Form::Testplans;

=head1 NAME

BoostedTest::C::Testplans - Catalyst Controller

=head1 DESCRIPTION

Catalyst Controller.

=head1 METHODS

=cut



=head2 index 
=cut


sub index : Private {
    my ( $self, $c ) = @_;
    $c->stash->{template} = 'testplans/index.html';
    #$c->response->body('Matched BoostedTest::C::Testplans in Testplans.');
}

sub create : Local {
    my ( $self, $c ) = @_;
    my $form = BoostedTest::Form::Testplans::Edit->new();
    $form->context_init($c);

	my $testplan = $c->model('Testplan')->create();
    my $iterator = $c->model('Testplan')->manager->get_testplans_iterator;
    if ( $form->was_submitted and $form->validate ) {
    	
    	$testplan = $form->testplan_from_form($testplan);
    	$testplan->save;
    	$c->stash->{message} = "Added!";
    }
    $c->stash->{testplans} = $iterator;
    $c->stash->{form} = $form;
    $c->stash->{template} = 'testplans/create.html';
}



sub import : Local {
    my ( $self, $c ) = @_;
    $c->stash->{template} = 'testplans/import/index.html';
}



=head1 AUTHOR

A clever guy

=head1 LICENSE

This library is free software, you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

1;
